import request from '@/utils/request'

/**
 * 获取商品的详细信息
 * @param {String} id -- 商品的id
 */
export const findGoods = (id) => {
  return request('/goods', 'get', { id })
}

/**
 *
 * @param {*} param0 -商品id，传入相关推荐，不传猜你喜欢
 * @returns Promise
 */
export const findRelevantGoods = ({ id, limit = 16 }) => {
  return request('/goods/relevant', 'get', { id, limit })
}

/**
 *
 * @param {String} id -商品的id
 * @param {String} limit -商品数量
 * @param {String} type - 热销类型,1为24小时,2为周热销榜,3为总热销榜
 * @returns
 */
export const findGoodsHot = ({ id, limit = 4, type }) => {
  return request('/goods/hot', 'get', { id, limit, type })
}

/**
 * 获取商品的评价统计信息
 * @param {String} id - 商品ID
 */
export const findGoodsCommentInfo = (id) => {
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate`, 'get')
}

/**
 * 获取商品的评价列表
 * @param {String} id - 商品ID
 * @param {Object} params - 评论参数
 */
export const findGoodsCommentList = (id, params) => {
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate/page`, 'get', params)
}
